﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;
using System.Data.SqlClient;
using System.IO;
using System.Security.Cryptography;

namespace prjCompras
{
    public partial class formteste : Form
    {
        public formteste()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sql = @"Select Codigo, Data, Case when Situacao = 0 then 'Não Analisada'
                            when Situacao = 1 then 'Aprovada' else 'Reprovada' end Situacao from Requisicao
                           where codigo = @cod";
            SqlDataAdapter dt =  Conexao.getInstance.executeQueryRelatorio(sql);
            dt.SelectCommand.Parameters.Add(new SqlParameter("@cod", textBox1.Text));
            dtstRequisicao dt_req = new dtstRequisicao();
            dt.Fill(dt_req, "Requisicao");

            sql = SqlCrud.getInstance.selectAll("RequisicaoMaterial");
            dt = Conexao.getInstance.executeQueryRelatorio(sql);
            dt.Fill(dt_req, "RequisicaoMaterial");

            sql = SqlCrud.getInstance.selectAll("Material");
            dt = Conexao.getInstance.executeQueryRelatorio(sql);
            dt.Fill(dt_req, "Material");

            rptRequisicao rel = new rptRequisicao();
            rel.SetDataSource(dt_req);
            frmRelatorio f = new frmRelatorio();
            f.Text = "Relatório de Requisições";
            f.crystalReportViewer1.ReportSource = rel;
            f.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            StreamReader texto = new StreamReader("C:\\conexao.txt");
            string msg = texto.ReadLine();

            MessageBox.Show(msg);
            MessageBox.Show(Application.StartupPath);



        }
    }
}
